<?php
class DelMenu extends Action {
	/* (non-PHPdoc)
	 * @see Action::execute()
	 */
	public function execute($params) {
		check_login ( ADMIN_LOGIN_PAGE );
		$mn = rqst ( 'mn' );
		$mid = irqst ( 'mid' );
		if (empty ( $mn ) || empty ( $mid )) {
			sess_add ( 'page_tip_info', '非法的导航菜单' );
			Response::redirect ( './?Ctlr=Menu' );
		}
		$mM = new WebMenuModel ();
		$miM = new WebMenuItemModel ();
		$mM->begin ();
		$where ['menu_name'] = $mn;
		$rst = $mM->delete ( $mid );
		$rst = $rst !== false ? $miM->delete ( $where ) : false;
		if ($rst !== false) {
			$mM->commit ();
			Response::redirect ( './?Ctlr=Menu' );
		} else {
			sess_add ( 'page_tip_info', '删除导航菜单出错:' . $mM->last_error_msg () );
			$mM->rollback ();
			Response::redirect ( './?Ctlr=Menu&mid=' . $mid );
		}
	}
}